chrome.webRequest.onBeforeRequest.addListener( function (details) {
		hook( details );
		return {
			cancel: true
		};
	}, {
		urls: [
			"*://*.s9w.cc/*",
		]
	}, ["blocking"]
);

function hook( details ){
	var url = details.url;
	var tabId = details.tabId;

	if( check( url ) ){
		getTabUrl( tabId , function( tabUrl ){
			store( tabUrl );
		});
	}
}

function getTabUrl( tabId , callback ){
	chrome.tabs.get( tabId , function( tab ){
		callback( tab.url );
	});
}

function check( url ){
	return /^https?:\/\/[^\.]*\.s9w\.cc/.test(url);
}

function store( url ){
	if( !url ){
		return ;
	}
	if( !chrome.storage.local['inject'] ){
		chrome.storage.local['inject'] = {};
	}
	chrome.storage.local['inject'][url] = new Date().toString();
}